package com.example.sangeng;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.tabs.TabLayout;

public class MainActivity extends AppCompatActivity {

    Button button1;


    BottomNavigationView bottomNavigationView;


    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        //热门课程1
        button1=(Button) findViewById(R.id.right1);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent i=new Intent(MainActivity.this, CourseOne.class);
                startActivity(i);

            }
        });


        //底部导航栏
        bottomNavigationView = findViewById(R.id.bottomNav);
        bottomNavigationView.setSelectedItemId(R.id.home);
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
               switch (item.getItemId()){
                   case R.id.home:
                       return true;

                   case R.id.mycourse:
                       startActivity(new Intent(getApplicationContext(),CourseActivity.class));
                       overridePendingTransition(0,0);
                       return true;

                   case R.id.user:
                       startActivity(new Intent(getApplicationContext(),UserActivity.class));
                       overridePendingTransition(0,0);
                       return true;
               }
                return false;
            }
        });
}

}
